import request from './request'
import { useUserStore } from '../store/modules/user'
import { AxiosPromise } from 'axios'
// 获取企业信息
export function getCustomerInfo() {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/system/customer/getCustomerInfo',
    method: 'get',
    headers: token,
  })
}

// 修改企业信息
export function updateCustomer(data) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/system/customer/updateCustomer',
    method: 'PUT',
    headers: token,
    data,
  })
}

// 获取系统全局设置
export function getSysSetOverall() {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/set/getSysSetOverall',
    method: 'get',
    headers: token,
  })
}

// 更新系统全局设置
export function saveSysSetOverall(data: any) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/set/saveSysSetOverall',
    method: 'put',
    headers: token,
    data,
  })
}

// 上传Logo
export function logoUpload(data: any) {
  return request({
    url: '/logo/logoUpload',
    method: 'post',
    headers: { 'access-token': useUserStore().token, 'Content-Type': 'multipart/form-data' },
    data,
  })
}

// 获取知识库查看权限
export function getKnowledgerSelectAuthor() {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/set/getKnowledgerSelectAuthor',
    method: 'get',
    headers: token,
  })
}

/**
 * 数据备份
 * @param {string} uuid - websocket唯一标识符
 */
export function dataBackup(uuid: string): AxiosPromise<APIResponse> {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: `/backup/${uuid}`,
    method: 'get',
    headers: token,
  })
}
